package com.haizhi.workstation.redis.key;

/**
 * 基础业务存储到redis中的前缀设计方式
 */
public class BaseKeyPrefix implements KeyPrefix {
    private String prefix;
    //过期时间
    private int expireSeconds;
    public BaseKeyPrefix(){}

    public BaseKeyPrefix(String prefix, int expireSeconds) {
        this.prefix = prefix;
        this.expireSeconds = expireSeconds;
    }

    /**
     * 当前实际类型的简单类型加上前缀 规则作为前缀
     * @return
     */
    @Override
    public String getPrefix() {
        return this.getClass().getSimpleName()+":"+prefix;
    }

    @Override
    public int getExpireSeconds() {
        return this.expireSeconds;
    }
}
